<template>
	<view>
		<view v-for="(item, index) in list" :key="index" class="item" @click="itemClick(item)">
			<view class="info">
				<view class="name">
					{{item.title}}
				</view>
				<view class="order">
					{{item.orderSn}}
				</view>
			</view>
			<view class="bal">
				{{item.totalAmount}}({{item.payStatus === 1 ? '已付':'未付'}})
			</view>
			<u-icon name="arrow-right" color="#A6A6A6" :size="18"></u-icon>
		</view>
	</view>
</template>

<script>
	import { getOrderList } from '@/api/pay.js'
	export default {
		props: {
			payStatus: {
				type: String,
				default () {
					return ''
				}
			},
		},
		data() {
			return {
				tabList: [{
					name: '未缴'
				}, {
					name: '已缴'
				}, {
					name: '全部',
				}],
				current: 0,
				
				list: []
			}
		},
		created() {
			this.getList();
			const that = this;
			uni.$on('paySuccess',function(data){
				that.getList();
			})
		},
		methods: {
			change(index) {
				this.current = index;
			},
			
			itemClick(item) {
				uni.navigateTo({
					url: `/pages_base/charge/detail-page?id=${item.id}`,
				})
			},
			
			getList() {
				uni.showLoading()
				getOrderList({payStatus: this.$props.payStatus}).then(res => {
					console.log(res);
					uni.hideLoading()
					this.list = res.data;
				})
			},
		}
	}
</script>

<style lang="scss">
	.container{
		padding-left: $app-page-padding;
		padding-right: $app-page-padding;
		
		.item{
			background: #FFFFFF;
			border-radius: 20rpx;
			padding: 30rpx;
			margin-top: 20rpx;
			margin-bottom: 20rpx;
			
			display: flex;
			flex-direction: row;
			align-items: center;
			.info{
				display: flex;
				flex-direction: column;
				flex-grow: 1;
				.name{
					
				}
				.order{
					margin-top: 10rpx;
				}
			}
			.bal{
				margin-right: 10rpx;
				margin-left: 10rpx;
			}
		}
	}
</style>
